# 构建阶段
FROM node:18.17.0-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# 生产阶段
FROM node:18.17.0-alpine
WORKDIR /app

# 从构建阶段复制 standalone 输出
COPY --from=builder /app/.next/standalone ./
# 复制 public 目录
COPY --from=builder /app/public ./public
# 复制 .next/static 到 .next/static
COPY --from=builder /app/.next/static ./.next/static

EXPOSE 3000

# 启动服务
CMD ["node", "server.js"]